-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: optimize with iterators #3652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
web3/_utils/abi.py
Outdated
|
||
@curry | ||
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> List[Any]: | ||
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> "map[ABITypedData]": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea for more optimization: rip out this func and replace it with a lambda which would have less overhead than using curry
web3/_utils/abi.py
Outdated
[abi_data_tree(types)], | ||
map(data_tree_map, normalizers), | ||
[partial(recursive_map, strip_abi_type)], | ||
return pipe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be further optimized by caching the pipe per-method as a compose
object
11a0672
to
67b1fbc
Compare
This looks like a combination of a few of your other PRs? Feel free to ping me once tests are passing, and let me know the order I should look at them. Thanks! |
Yes, this was the original PR that ended up going beyond its scope. I wanted to make it easier on you so I'm rebasing this one as we handle the others and we can handle it towards the end. |
I've rebased this on top of all the PRs we merged and this is now just one minor tweak, ready for review. tldr we were initing tuples that weren't necessary and can just pass generators around instead this does change the API but both functions are internal and the codebase handles the change just fine |
What was wrong?
The formatters init quite a few lists each run, and can be made much more efficient using iterators. This PR does so.
I figured this was more important than the logger stuff in my last PR so finished this one up first.
Related to Issue # N/A
Closes # N/A
How was it fixed?
creation of an IteratorProxy class that allows
map
objects to be passed thru the formatters instead of fully materializing a list every step of the wayTodo:
Cute Animal Picture